#include "stm32f10x.h"                  // Device header
#include "LED.h"
#include "Usart.h"
#include "Delay.h"

char dat1[]="AT+RST\r\n",\
	 dat2[]="AT+CWMODE=2\r\n",\
	 dat3[]="AT+CWSAP_DEF=\"ESP8266AP_test\",\"12345678\",1,3\r\n",\
	 dat4[]="AT+CIPMUX=0\r\n",\
     dat5[]="AT+CIPSERVER=0\r\n",\
	 dat6[]="AT+CIPSTART=\"TCP\",\"192.168.4.2\",8080\r\n",\
	 dat7[]="AT+CIPMODE=1\r\n",\
     dat8[]="AT+CIPSEND\r\n",\
	 dat9[]="hello!!! I am ESP-01S\r\n";
void ESP8266_Init()
{
	Usart1_SendString(dat1);
	Delay_ms(500);
	Usart1_SendString(dat2);
	Delay_ms(100);
	Usart1_SendString(dat3);
	Delay_ms(100);
	Usart1_SendString(dat4);
	Delay_ms(100);
	Usart1_SendString(dat5);
	Delay_ms(100);
	
	LED1_ON();
}

void ConnectTCP_Server()
{
	Usart1_SendString(dat6);
	Delay_ms(500);
	Usart1_SendString(dat7);
	Delay_ms(100);
	Usart1_SendString(dat8);
	Delay_ms(100);
	Usart1_SendString(dat9);
	Delay_ms(100);
}
